package com.hinnotek.amoeba.adapters.old

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.hinnotek.amoeba.R
import com.hinnotek.amoeba.adapters.old.viewholder.ABaseViewHolder
import com.hinnotek.amoeba.bean.old.RelatePurchasingBean

class RelatePurchaseListAdapter :
    BaseQuickAdapter<RelatePurchasingBean, ABaseViewHolder>(R.layout.item_relate_purchas_list) {
    override fun convert(holder: ABaseViewHolder, item: RelatePurchasingBean) {
        if (item.b == 0) {
            holder.setChecked(R.id.cb_purchase_choose, false)
        } else {
            holder.setChecked(R.id.cb_purchase_choose, true)
        }
        holder.getView<View>(R.id.cb_purchase_choose)
            .setOnClickListener { callBack!!.onClick(item, holder.position) }
    }

    private var callBack: ClickCallBack? = null
    fun setIdCallBack(callBack: ClickCallBack?) {
        this.callBack = callBack
    }

    interface ClickCallBack {
        fun onClick(bean: RelatePurchasingBean?, position: Int)
    }
}